import request from '@/utils/request'

// 获取课程列表
export function getCourseList(data) {
  return request({
    url: '/course/list',
    method: 'post',
    data
    // data
  })
}

// 新增课程
export function addCourse(data) {
  return request({
    url: '/course/add',
    method: 'post',
    data
  })
}
// 图片上传
export function upload(data) {
  return request({
    url: '/api/course/upload',
    method: 'post',
    data
  })
}


// 更新课程
export function updateCourse(data) {
  return request({
    url: `/course/${data.id}`,
    method: 'put',
    data
  })
}

// 删除课程
export function deleteCourse(id) {
  return request({
    url: `/course/${id}`,
    method: 'delete'
  })
}

// 切换课程状态
export function toggleCourseStatus(id) {
  return request({
    url: `/course/${id}/toggle-status`,
    method: 'put'
  })
}

export default {
  getPage: (params) => request.get('/courses/page', { params }),
  add: (data) => request.post('/courses', data),
  update: (data) => request.put('/courses', data),
  delete: (id) => request.delete(`/courses/${id}`),
  getById: (id) => request.get(`/courses/${id}`),
  upload: (data) => request.post('/courses/upload', data)
} 